package com.ipoint.intr.smartCatalog.model.element;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;

import org.hibernate.validator.NotNull;

import com.ipoint.intr.smartCatalog.model.BaseObject;

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Value extends BaseObject {

	@NotNull
	private String name;

	@ManyToOne(fetch = FetchType.EAGER)
	private Element element;

	public Element getElement() {
		return element;
	}

	public void setElement(Element element) {
		this.element = element;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	protected void toStringValues(StringBuffer result) {
		super.toStringValues(result);
		result.append(",").append("name-").append(this.getName());
		result.append(",").append("elementId-").append(
				toStringId(this.getElement()));
	}

	public String getType() {
		return this.getClass().getSimpleName();
	}

}
